Skip to content

Bundle the plugin SDK declaration files in parallel worker threads - #2304

Merged
SawyerHood merged 1 commit into
mainfrom
bb/parallel-dts-bundles
Aug 22, 2026
Merged

Bundle the plugin SDK declaration files in parallel worker threads#2304
SawyerHood merged 1 commit into
mainfrom
bb/parallel-dts-bundles

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

What was wrong

@get-bb/plugin-sdk#build:types (scripts/build-bundled-dts.mjs) produces the 13 portable declaration bundles one after another. Each rollup-plugin-dts bundle builds its own TypeScript 6 program over the SDK sources plus the inlined @bb/* workspace sources; the six large entries take 2–7 s apiece and the task takes ~27 s on a 16-core machine. It gates @bb/host-daemon#build, @bb/cli#test, @bb/templates#test, and @bb/integration-tests#typecheck.

What changed

The bundles are independent, so the script re-runs itself as a worker_threads worker per entry, keeping as many in flight as os.availableParallelism(). The main thread still writes the outputs in the declared order with the same unchanged-file check and atomic rename. Nothing about the bundling itself changed.

How you verified

sha256sum bundled-types/*.d.ts is identical before and after for all 13 files, both on 16 cores and pinned to 4 CPUs. Wall time: 27.0 s → 10.6 s on 16 cores; 27 s → 17.8 s pinned to 4 CPUs standalone. Inside a 4-CPU emulation of the CI "Checks" job (taskset -c 0-3 turbo run build typecheck lint --force --concurrency=4, two rounds each) the job measured 118 s / 99 s serial vs 92 s / 103 s parallel — within run-to-run noise, so expect no CI regression and a clear local win. pnpm exec turbo run test --filter=@get-bb/plugin-sdk --filter=@bb/templates --force and turbo run typecheck --filter=@bb/integration-tests --filter=@bb/host-daemon --force pass against the new bundles.

No linked issue.

AGENT GENERATED

build-bundled-dts.mjs ran its 13 rollup-plugin-dts bundles one after
another, and each builds its own TypeScript program; the six large entries
take 2-7s apiece, 27s in total. The entries are independent, so the script
now re-runs itself as a worker thread per entry, as many at a time as there
are cores. Output is byte-identical; on a 16-core machine the task drops to
~10s. On a 4-CPU runner that is already saturated by turbo it is neutral.

Co-Authored-By: Claude <noreply@anthropic.com>
@SawyerHood
SawyerHood merged commit 7bb7f26 into main Aug 22, 2026
15 checks passed
@SawyerHood
SawyerHood deleted the bb/parallel-dts-bundles branch August 22, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants